<?php

namespace IDock\Insurance\JTIC\Response;

use IDock\Http\Response;
use IDock\Insurance\JTIC\Response\AllJTICResponse;
use IDock\Printer\PolicyPaymentPrinter;

class PolicyPaymentResponse extends AllJTICResponse
{

    /**
     * @var PolicyPaymentPrinter $printer
     */
    public $printer = PolicyPaymentPrinter::class;

    public function printerInit(): Response
    {
        $data = $this->getBody();
        $url = $data['BasePart']['PayUrl'] ?? '';
        if(empty($url)){
            $this->setError('支付失败');
            return $this;
        }
        $this->printer->payUrl = $url;
        return $this;
    }
}
